/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package newkfp;

import java.io.Serializable;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author labib.farag
 */
@Stateless
public class EmployeeFacade extends AbstractFacade<Employee> implements Serializable{
    @PersistenceContext(unitName = "KFPNEWPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public EmployeeFacade() {
        super(Employee.class);
    }

  public  Employee checkUserLogin(String userName, String pass) {
        try {
            Query query = getEntityManager().createNamedQuery("Employee.login");
            query.setParameter("userName", userName);
            query.setParameter("pass", pass);
            return (Employee) query.getSingleResult();
        } catch (Exception ex) {
            return null;
        }
    }
    
}
